package com.lee.controller;

import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 * Created by 维C果糖 on 2017/1/24.
 */
public class HelloController2 extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response) throws Exception {

        System.out.println(request.getRequestURI());  // 获取Controller的名称，即地址

        ModelAndView mModelAndView = new ModelAndView("hello");
        // mModelAndView.addObject("msg", "HelloController2");
        // mModelAndView.addObject("name", "维C果糖");
        ModelMap model = new ModelMap();
        model.addAttribute("msg", "HelloController2");
        model.addAttribute("name", "维C果糖");
        model.addAttribute("path", request.getRequestURI());
        mModelAndView.addAllObjects(model);
        return mModelAndView;  // 逻辑名
    }
}
